﻿<Window x:Class="TeamProjectManager.Modules.WorkItemConfiguration.WorkItemConfigurationItemTransformationEditorDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="clr-namespace:TeamProjectManager.Common.Infrastructure;assembly=TeamProjectManager.Common"
        xmlns:c="clr-namespace:TeamProjectManager.Common.Converters;assembly=TeamProjectManager.Common"
        xmlns:w="clr-namespace:TeamProjectManager.Modules.WorkItemConfiguration"
        Title="Transform Work Item Configuration Items"
        WindowStartupLocation="CenterOwner"
        ShowInTaskbar="False"
        Height="600"
        Width="800">
    <Window.Resources>
        <c:XmlDocumentConverter x:Key="xmlDocumentConverter" />
    </Window.Resources>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <GroupBox Grid.Column="0" Header="Input">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <ComboBox Grid.Row="0" x:Name="selectedItemComboBox" ItemsSource="{Binding Path=Items}" SelectedItem="{Binding Path=SelectedItem}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock>
                                    <TextBlock.Text>
                                        <MultiBinding StringFormat="{}{0} ({1})">
                                            <Binding Path="Item.Name" />
                                            <Binding Path="TeamProject.Name" />
                                        </MultiBinding>
                                    </TextBlock.Text>
                                </TextBlock>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <TextBox x:Name="inputTextBox" Grid.Row="1" Text="{Binding ElementName=selectedItemComboBox, Path=SelectedItem.Item.XmlDefinition, Converter={StaticResource xmlDocumentConverter}}" TextChanged="inputTextBox_TextChanged" IsReadOnly="True" IsReadOnlyCaretVisible="True" AcceptsReturn="True" TextWrapping="NoWrap" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,5,0,0" i:FindProvider.FindEnabled="true" />
                </Grid>                
            </GroupBox>

            <GridSplitter Grid.Column="1" Width="3" Margin="3,0,3,0" HorizontalAlignment="Stretch" ResizeDirection="Columns" />

            <GroupBox Grid.Column="2" Header="Transformation">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    
                    <Grid Grid.Row="0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0" Content="Load" x:Name="loadTransformation" Click="loadTransformation_Click" />
                        <WrapPanel Grid.Column="1" Margin="5,0,0,0">
                            <Label Content="Type:" VerticalAlignment="Center" />
                            <RadioButton Margin="5,0,0,0" Content="XDT" IsChecked="{Binding Path=TransformationType, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Xdt}" ToolTip="Uses the XML Document Transformation language which is typically used for Web.config transformations" VerticalAlignment="Center" Checked="transformationType_Changed" />
                            <RadioButton Margin="5,0,0,0" Content="XSLT" IsChecked="{Binding Path=TransformationType, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Xslt}" ToolTip="Uses the XSLT 1.0 language" VerticalAlignment="Center" Checked="transformationType_Changed" />
                        </WrapPanel>
                    </Grid>

                    <TextBox Grid.Row="1" AcceptsReturn="True" x:Name="transformationTextBox" TextChanged="transformationTextBox_TextChanged" Margin="0,5,0,0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" i:FindProvider.FindEnabled="true" />
                </Grid>
            </GroupBox>

            <GridSplitter Grid.Column="3" Width="3" Margin="3,0,3,0" HorizontalAlignment="Stretch" ResizeDirection="Columns" />

            <GroupBox Grid.Column="4" Header="Output">
                <TextBox x:Name="outputTextBox" AcceptsReturn="True" IsReadOnly="True" IsReadOnlyCaretVisible="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" i:FindProvider.FindEnabled="true" />
            </GroupBox>
        </Grid>

        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,5,0,0">
            <CheckBox Content="Simulate only" ToolTip="Does not save any changes but simulates the process" IsChecked="{Binding Path=Simulate}" VerticalAlignment="Center" />
            <CheckBox Content="Save a copy" ToolTip="Saves a copy of the imported files to the %TEMP% folder" IsChecked="{Binding Path=SaveCopy}" VerticalAlignment="Center" Margin="5,0,0,0" />
            <TextBlock VerticalAlignment="Center" Margin="5,0,0,0"><Hyperlink x:Name="macroInformationHyperlink" Command="{x:Static w:MacroInformationDialog.ShowInstanceCommand}">About macros</Hyperlink></TextBlock>
            <Button Content="OK" IsDefault="True" Width="75" x:Name="okButton" Click="okButton_Click" Margin="5,0,0,0" />
            <Button Content="Cancel" IsCancel="True" Width="75" Margin="5,0,0,0" />
        </StackPanel>
    </Grid>
</Window>
